package cn.doitedu.demo4.utils;

import cn.doitedu.demo4.beans.EventBean;
import cn.doitedu.demo4.beans.RuleMetaBean;
import lombok.Getter;
import org.apache.flink.api.common.state.ListStateDescriptor;
import org.apache.flink.api.common.state.MapStateDescriptor;
import org.apache.flink.api.common.state.StateTtlConfig;
import org.apache.flink.api.common.time.Time;

public class StateDescUtil {

    @Getter
    private static MapStateDescriptor<String, RuleMetaBean> metaBcStateDesc = new MapStateDescriptor<>("meta_bc_state", String.class, RuleMetaBean.class);

    @Getter
    private static MapStateDescriptor<String, String> oldCalculatorIdsDesc = new MapStateDescriptor<>("old_calculator_ids", String.class, String.class);



    public static ListStateDescriptor<EventBean> getRecentEventsListStateDesc() {
        ListStateDescriptor<EventBean>  recentEventStateDesc =  new ListStateDescriptor<EventBean>("recent_events_state",EventBean.class);
        StateTtlConfig ttlConfig = StateTtlConfig.newBuilder(Time.seconds(10)).build();
        recentEventStateDesc.enableTimeToLive(ttlConfig);

        return recentEventStateDesc;
    }
}
